package com.woniu.controller;

import com.woniu.entity.ResponseEntity;
import com.woniu.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.security.auth.login.LoginException;

/**
 * @author WenXin
 * @version 1.0
 * @description: TODO
 * @date 2022/8/31 20:04
 */
@RestController
@CrossOrigin //解决跨域问题
public class LoginController {
    @Autowired
    LoginService loginService;

    @RequestMapping("/login")
    public ResponseEntity login(String username, String password) throws LoginException {


        return loginService.login(username, password);
    }

    @RequestMapping("/401")
    public ResponseEntity response401() {
        return ResponseEntity.AUTHFAILED;
    }
}
